USE Clinic 
GO

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[up_NursesUpdateUserIdForNurse]
	@NurseId int
	, @UserId uniqueidentifier
AS
BEGIN
	
	SET NOCOUNT ON;
	BEGIN TRANSACTION 
	-- Clear all mapped users before inserting new one--
		exec up_Personnel_ClearInfoForUserId @UserId
			
		UPDATE Nurses
		SET [UserId] = @UserId
		WHERE @NurseId = [NurseId];
		
		IF @@Error <> 0 
			BEGIN
				ROLLBACK 
				RETURN 
			END
    COMMIT
END

